<template>
  <div class="box">
    <div class="total_num">
      <div class="total_box">
        <div class="img_box">
          <div class="icon2"></div>
        </div>
        <div class="num_box">
          <span>客户总数量</span>
          <span class="total_count">{{ totalCount }}个</span>
        </div>
      </div>
    </div>
    <div class="num">
      <div class="num_title" v-for="item in props.data" :key="item.name">
        <div class="num_img">
          <img src="../../img/card.png" />
        </div>

        <span class="num_title_text" 
          >{{ item.name }} <span style="color: rgba(255, 255, 255, 0.4);">({{ item.type === 1 ? "个" : "万" }})</span></span
        >
        <span class="num_text">{{ item.value }}</span>
      </div>
      <!-- <div class="num_title">
        <span class="num_title_text">新签约客户(个)</span>
        <span>1234</span>
      </div>
      <div class="num_title">
        <span class="num_title_text">续签客户(个)</span>
        <span>1234</span>
      </div>
      <div class="num_title">
        <span class="num_title_text">历史客户(个)</span>
        <span>1234</span>
      </div> -->
    </div>
  </div>
</template>

<script setup>
import { watchEffect, ref } from "vue";
const props = defineProps({
  data: {
    type: Array,
    default: () => {
      return [];
    },
  },
});
const totalCount = ref(0);
watchEffect(() => {
  if (props.data.length) {
    totalCount.value = props.data.reduce((a, b) => {
      return a + b.value * 1;
    }, 0);
  }
});
</script>

<style scoped>
.box {
  margin-top: 20px;
  width: 100%;
  height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.total_num {
  width: 90%;
  height: 59px;
  border-radius: 33.5px;
  opacity: 1;
  background-color: red;

  background: linear-gradient(
      133deg,
      rgba(255, 255, 255, 0.15) 11%,
      rgba(255, 255, 255, 0) 20%
    ),
    rgba(0, 0, 0, 0.01);

  box-sizing: border-box;
  border: 2px solid rgba(70, 134, 187, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.num {
  position: relative;
  width: 100%;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}
.num_img {
  position: absolute;
  opacity: 0.3;
  width: 100%;
  height: 100%;
  /* background: url("../../img/card.png") no-repeat;
  background-size: contain; */
}
.num_img img {
  width: 100%;
  height: 100%;
}
.num_title {
  position: relative;
  width: 22%;
  height: 100%;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;

  font-size: 22px;
  font-weight: bold;
  line-height: 14px;
  text-align: center;
  letter-spacing: 0px;

  background: linear-gradient(180deg, #19c0ff 0%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-fill-color: transparent;
}
.num_title_text {
  font-size: 14px;
  font-weight: bold;
  line-height: 14px;
  z-index: 99;
  

  color: #ffffff;
}
.num_text {
  background-image: -webkit-linear-gradient(
    bottom,
    rgba(25, 192, 255, 1),
    rgba(255, 255, 255, 1)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.total_box {
  width: 260px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.img_box {
  position: relative;
  width: 64px;
  height: 52px;
  background: url("../../img/icon1.png") no-repeat;
  background-size: cover;
}
.icon2 {
  position: absolute;
  top: 10px;
  left: 24px;
  width: 22px;
  height: 22px;
  background: url("../../img/icon2.png") no-repeat;
  background-size: cover;
}
.num_box {
  width: 70%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  font-size: 18px;
}
.total_count {
  font-size: 22px;
  font-weight: 800;
}
</style>
